<template>
	<view id="scroll">
		<mescroll-uni height="72.4%"
									@down="downCallback" 
									@up="upCallback"
									@init="mescrollInit"
									:up="upOption" 
									class="message">
			<slot></slot>
		</mescroll-uni>
	</view>
</template>

<script>
	import Add from './Add.vue'
	import MescrollUni from "../../uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue"
	export default {
		name: 'Scroll',
		components: {
			MescrollUni,
			Add
		},
		props: {
			total: {
				type: Number,
				default() {
					return 0
				}
			},
			currentPage:{
				type: Number,
				default() {
					return 0
				}
			}
		},
		data() {
			return {
				isShowNoMore:false,
				upOption: {
					textNoMore:'没有更多了 >_<',
					toTop: {
						right: 70,
						bottom: 200
					}
				}
			}
		},
		methods: {
			mescrollInit(mescroll) {
				console.log(mescroll)
				// this.$emit('updateData')
			},
			downCallback(mescroll){
				// setTimeout(()=>{
					// console.log(333)
					// this.$emit('updateData')
					mescroll.endErr()
				// },1000)
			},
			upCallback(mescroll){
				setTimeout(()=>{
					if(this.currentPage < this.total) {
						this.$emit('pullUpLoad')
						this.isShowNoMore = false;
						mescroll.endUpScroll(this.isShowNoMore);
					} else {
						this.isShowNoMore = true;
						mescroll.endUpScroll(this.isShowNoMore);
					}
				},1000)
			}
		}
	}
</script>

<style scoped>
</style>
